package com.zhadafei.mvnbook.account.captcha;

import java.util.Random;

public class RandomGenerator {
	private static String range = "0123456789abcdefghijklmnopqrstuvwxyz";

	/**
	 * 随机生成一个8位的字符串
	 * @return
	 */
	public static synchronized String getRandomString() {
		Random random = new Random();
		StringBuffer result = new StringBuffer();
		for (int i = 0; i < 8; i++) {
			//获取指定位置的字符追加到字符中来
			result.append(range.charAt(random.nextInt(range.length())));
		}
		return result.toString();
	}
}